package com.htzos.common.util;

import java.util.Collection;
import java.util.Map;

public class ParameterUtil {

	/**
	 * 验证参数是否为空
	 * 
	 * @param params
	 * @return
	 */
	public static boolean isBlankParams(final String... params) {
		if (null == params || 0 == params.length) {
			return true;
		}
		for (String param : params) {
			if (param == null || "".equals(param) || "undefined".equals(param)) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 验证参数是否为空
	 * 
	 * @param params
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	public static boolean isBlankParams(final Object... params) {
		if (null == params || 0 == params.length) {
			return true;
		}
		for (Object param : params) {
			if (param == null) {
				return true;
			} else {
				if (param instanceof String) {
					if ("".equals(param) || "undefined".equals(param)) {
						return true;
					}
				} else if (param instanceof Object[]) {
					if ((((Object[]) param).length == 0)) {
						return true;
					}
				} else if (param instanceof Collection) {
					if (((Collection) param).size() == 0) {
						return true;
					}
				} else if (param instanceof Map) {
					if (((Map) param).size() == 0) {
						return true;
					}
				}
			}
		}
		return false;
	}

	/**
	 * 验证字符串是否为空
	 * 
	 * @param str
	 * @return
	 */
	public static boolean isBlank(String str) {
		return str == null || str.length() == 0;
	}

}
